<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>value_ref</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.JSON">
<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
<link rel="prev" href="boost__json__value_from_tag.html" title="value_from_tag">
<link rel="next" href="boost__json__value_ref/value_ref.html" title="value_ref::value_ref">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__value_from_tag.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__value_ref/value_ref.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="json.ref.boost__json__value_ref"></a><a class="link" href="boost__json__value_ref.html" title="value_ref">value_ref</a>
</h4></div></div></div>
<p>
        The type used in initializer lists.
      </p>
<h5>
<a name="json.ref.boost__json__value_ref.h0"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_ref.synopsis"></a></span><a class="link" href="boost__json__value_ref.html#json.ref.boost__json__value_ref.synopsis">Synopsis</a>
      </h5>
<p>
        Defined in header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json/value_ref.hpp" target="_top">boost/json/value_ref.hpp</a>&gt;</code>
      </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">value_ref</span>
</pre>
<h5>
<a name="json.ref.boost__json__value_ref.h1"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_ref.member_functions"></a></span><a class="link" href="boost__json__value_ref.html#json.ref.boost__json__value_ref.member_functions">Member
        Functions</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__value_ref/value_ref.html" title="value_ref::value_ref">value_ref</a> <span class="silver">[constructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Constructor.
                </p>
              </td>
</tr></tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__value_ref.h2"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_ref.description"></a></span><a class="link" href="boost__json__value_ref.html#json.ref.boost__json__value_ref.description">Description</a>
      </h5>
<p>
        This type is used in initializer lists for lazy construction of and assignment
        to the container types <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>, <a class="link" href="boost__json__array.html" title="array"><code class="computeroutput"><span class="identifier">array</span></code></a>, and <a class="link" href="boost__json__object.html" title="object"><code class="computeroutput"><span class="identifier">object</span></code></a>. The two types of initializer
        lists used are:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span>
            <span class="identifier">value_ref</span> <span class="special">&gt;</span></code>
            for constructing or assigning a <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a> or <a class="link" href="boost__json__array.html" title="array"><code class="computeroutput"><span class="identifier">array</span></code></a>, and
          </li>
<li class="listitem">
            <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span>
            <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span>
            <span class="identifier">string_view</span><span class="special">,</span>
            <span class="identifier">value_ref</span> <span class="special">&gt;</span>
            <span class="special">&gt;</span></code> for constructing or assigning
            an <a class="link" href="boost__json__object.html" title="object"><code class="computeroutput"><span class="identifier">object</span></code></a>.
          </li>
</ul></div>
<p>
        A <code class="computeroutput"><span class="identifier">value_ref</span></code> uses reference
        semantics. Creation of the actual container from the initializer list is
        lazily deferred until the list is used. This means that the <a class="link" href="boost__json__memory_resource.html" title="memory_resource"><code class="computeroutput"><span class="identifier">memory_resource</span></code></a> used to construct
        a container can be specified after the point where the initializer list is
        specified.
      </p>
<h5>
<a name="json.ref.boost__json__value_ref.h3"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_ref.example"></a></span><a class="link" href="boost__json__value_ref.html#json.ref.boost__json__value_ref.example">Example</a>
      </h5>
<p>
        This example demonstrates how a user-defined type containing a JSON value
        can be constructed from an initializer list:
      </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">my_type</span>
<span class="special">{</span>
    <span class="identifier">value</span> <span class="identifier">jv_</span><span class="special">;</span>

<span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">my_type</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span> <span class="identifier">value_ref</span> <span class="special">&gt;</span> <span class="identifier">init</span> <span class="special">)</span>
        <span class="special">:</span> <span class="identifier">jv_</span><span class="special">(</span><span class="identifier">init</span><span class="special">)</span>
    <span class="special">{</span>
    <span class="special">}</span>
<span class="special">};</span>
</pre>
<h5>
<a name="json.ref.boost__json__value_ref.h4"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_ref.remarks"></a></span><a class="link" href="boost__json__value_ref.html#json.ref.boost__json__value_ref.remarks">Remarks</a>
      </h5>
<p>
        Never declare a variable of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span></code>
        except in function parameter lists, otherwise the behavior may be undefined.
      </p>
<h5>
<a name="json.ref.boost__json__value_ref.h5"></a>
        <span class="phrase"><a name="json.ref.boost__json__value_ref.see_also"></a></span><a class="link" href="boost__json__value_ref.html#json.ref.boost__json__value_ref.see_also">See
        Also</a>
      </h5>
<p>
        <a class="link" href="boost__json__value.html" title="value"><code class="computeroutput"><span class="identifier">value</span></code></a>,
        <a class="link" href="boost__json__array.html" title="array"><code class="computeroutput"><span class="identifier">array</span></code></a>,
        <a class="link" href="boost__json__object.html" title="object"><code class="computeroutput"><span class="identifier">object</span></code></a>
      </p>
<p>
        Convenience header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json.hpp" target="_top">boost/json.hpp</a>&gt;</code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Vinnie Falco<br>Copyright © 2020 Krystian Stasiowski<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__value_from_tag.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__value_ref/value_ref.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
